/*
 * Powered By XY
 * Since 2020
 */

package com.xy.biz.base.manager.impl;

import com.xy.biz.base.dao.GoodsDao;
import com.xy.biz.base.domain.bo.GoodsBO;
import com.xy.biz.base.domain.converter.GoodsConverter;
import com.xy.biz.base.domain.po.GoodsPO;
import com.xy.biz.base.domain.query.GoodsQuery;
import com.xy.biz.base.manager.GoodsManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;

/**
 * 
 * 
 * @author zgy
 * @date 2021-9-22
 */
@Service
public class GoodsManagerImpl implements GoodsManager {

	@Autowired
	private GoodsDao goodsDao;
	
	@Override
	public int saveGoods(GoodsBO goodsBO) {
		return goodsDao.saveGoods(GoodsConverter.toPO(goodsBO));
	}
	
	@Override
	public int saveAllGoods(Collection<GoodsBO> collection) {
		return goodsDao.saveAllGoods(GoodsConverter.toPO(collection));
	}
	
	@Override
	public int updateGoods(GoodsBO goodsBO) {
		return goodsDao.updateGoods(GoodsConverter.toPO(goodsBO));
	}
	
	@Override
	public int deleteGoods(Long goodsId) {
		return goodsDao.deleteGoods(goodsId);
	}
	
	@Override
	public GoodsBO getGoods(Long goodsId) {
		return GoodsConverter.fromPO(goodsDao.getGoods(goodsId));
	}

	@Override
	public List<GoodsBO> listGoodsById(Collection<Long> collection) {
		return GoodsConverter.fromPO(goodsDao.listGoodsById(collection));
	}
	
	@Override
	public List<GoodsBO> listGoods(GoodsQuery query) {
		return GoodsConverter.fromPO(goodsDao.listGoods(query));
	}

	@Override
	public List<GoodsBO> listGoodsByCode(String goodsCode, boolean fuzzy) {
		return GoodsConverter.fromPO(goodsDao.listGoodsByCode(goodsCode, fuzzy));
	}

	@Override
	public List<GoodsBO> listGoodsByFullCode(String goodsFullCode, boolean fuzzy) {
		return GoodsConverter.fromPO(goodsDao.listGoodsByFullCode(goodsFullCode, fuzzy));
	}

	@Override
	public List<GoodsBO> listGoodsByAbbr(String goodsAbbr, boolean fuzzy) {
		return GoodsConverter.fromPO(goodsDao.listGoodsByAbbr(goodsAbbr, fuzzy));
	}

	@Override
	public int countGoods(GoodsQuery query) {
		return goodsDao.countGoods(query);
	}

}
